package com.hmall.mapper;

import com.hmall.model.MallOrder;
import com.hmall.util.MyMapper;
import com.hmall.vo.MallOrderManageVo;
import com.hmall.vo.OrderSelectItemVo;
import com.hmall.vo.OrderSelectVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;
import java.util.List;
@Repository
public interface MallOrderMapper extends MyMapper<MallOrder> {
    MallOrder selectByUserIdAndOrderNo(@Param("userId") Integer userId, @Param("orderNo") Long orderNo);

    MallOrder selectByOrderNo(Long orderNo);
    int selectComment(@Param("orderNo") Long orderNo);
    List<MallOrder> selectByUserId(Integer userId);

    List<MallOrder> selectAllOrder();

    List<MallOrderManageVo> selectOrder();

    List<MallOrderManageVo> selectSHZOrder(@Param("dept_id") Integer dept_id);

    List<MallOrderManageVo> selectWFKOrder(@Param("dept_id") Integer dept_id);

    List<MallOrderManageVo> selectYQXOrder(@Param("dept_id") Integer dept_id);

    List<MallOrderManageVo> selectYFKOrder(@Param("dept_id") Integer dept_id);

    List<MallOrderManageVo> selectYFHOrder(@Param("dept_id") Integer dept_id);

    List<MallOrderManageVo> selectJYCGOrder(@Param("dept_id") Integer dept_id);

    List<MallOrderManageVo> selectWQHTOrder(@Param("dept_id") Integer dept_id);

    List<MallOrderManageVo> selectHTSXOrder(@Param("dept_id") Integer dept_id);

    Integer cancelOrder(Integer id);

    Integer deliverOrder(Integer id);
    int deleteOrderByOrderNo(@Param("orderNo") Long orderNo);

    Integer updatePayment(@Param("orderId") Integer orderId, @Param("change_price") BigDecimal change_price);

    Integer updateOrder(@Param("id") Integer id, @Param("shipping_id") Integer shipping_id, @Param("distCode") Integer distCode);

    int updateByOrderId(String status, Integer orderId);
    int updatePaymentTypeOrder(@Param("orderNo") Long orderNo, @Param("paymentType") Integer paymentType);

    int updateByOrderNo(@Param("status") Integer status, @Param("order_no") Long order_no);
    //创建订单
    int insertOrderCart(@Param("orderNo") Long orderNo, @Param("order") OrderSelectVo order, @Param("dealerId") Integer dealerId);
    //批量创建订单
    int batchInsertOrder(@Param("orderList") List<OrderSelectVo> orderList);

    //查询最近三个月订单
     List<OrderSelectVo> selectOrderItemsByThreeMonth(
             @Param("status") Integer status,
             @Param("userId") Integer userId,
             @Param("startPage") Integer startPage,
             @Param("pageSize") Integer pageSize,
             @Param("orderNo") String orderNo,
             @Param("type") String type
     ) ;
    //查询最近三个月所有订单
     List<OrderSelectVo> selectAllOrderItemsByThreeMonth(@Param("userId") Integer userId, @Param("startPage") Integer startPage,
                                                         @Param("pageSize") Integer pageSize, @Param("orderNo") String orderNo, @Param("type") String type);
    //订单号查询订单
     OrderSelectVo selectOrderByOrderNo(@Param("oderNo") Long oderNo) ;
     //查询某个订单下的产品列表
    List<OrderSelectItemVo> selectOrderItemsByOrderNo(@Param("orderNo") Long orderNo);

    int selectOrderByThreeMonthCount(@Param("status") Integer status, @Param("userId") Integer userId
            , @Param("orderNo") String orderNo, @Param("type") String type);

    int selectAllOrderByThreeMonthCount(@Param("userId") Integer userId, @Param("orderNo") String orderNo, @Param("type") String type);

    //列出状态为50(交易成功) 的所有订单编号
    List<BigInteger> listSuccessOrderNo(@Param("SUCCESS") int SUCCESS);

    //列出状态为50（交易成功）的某个用户的所有订单编号
    List<BigInteger> listSuccessUserOrderNo(@Param("userId") Integer userId, @Param("SUCCESS") int success);

    //列出状态为50(交易成功)的更新时间
    Date selectUpdateTime(@Param("status") int status, @Param("productId") Integer productId);

    //删除某个用户的所有订单
    void deleteByUserId(@Param("userId") Integer userId);

    void changeOrderStatus(@Param("orderId") Integer orderId, @Param("status") Integer status);

    List<MallOrder> findOrderStatus(@Param("userId") Integer userId);

    void changeOrderStatusByOrderNo(@Param("orderNo") Long orderNo, @Param("status") int status);

    List<MallOrder> selectOldestHavePay(@Param("customerId") Integer customerId);

    MallOrder selectAllOrderNo(@Param("orderNo") Long orderNo);

    Integer selectSampleWithCustomerId(@Param("customerId") Integer customerId, @Param("start") Date start, @Param("end") Date end);

    void updateCreateReason(@Param("deviceType") String agent, @Param("orderNo") Long orderNo, @Param("purchaseType") String purchaseType);
}